package com.fivezerotwo.springbootserver.bll;

import com.fivezerotwo.springbootserver.dao.UserMapper;
import com.fivezerotwo.springbootserver.dto.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * Created by qiqi on 2018/7/10 20:03
 */
@Service
public class UserBll {

    @Autowired
    private UserMapper userMapper;

    public List<User> getUserList() {
        return userMapper.selectUsers();
    }

    public boolean addUser(String name, int userRole, String password) {
        User user = new User();
        String id = UUID.randomUUID().toString();
        user.setId(id);
        user.setUserRole(userRole);
        user.setName(name);
        user.setPassword(password);
        int ret = userMapper.insertSelective(user);
        return ret > 0 ? true : false;
    }

}
